<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Origami::ObjectStream</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Origami::ObjectStream</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/origami/stream_rb.html">
                origami/stream.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="Stream.html">
                Stream
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Class representing a <a href="Stream.html">Stream</a> containing other
Objects.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000480">&lt;&lt;</a>&nbsp;&nbsp;
      <a href="#M000482">delete</a>&nbsp;&nbsp;
      <a href="#M000487">each</a>&nbsp;&nbsp;
      <a href="#M000484">extract</a>&nbsp;&nbsp;
      <a href="#M000485">extract_by_index</a>&nbsp;&nbsp;
      <a href="#M000486">include?</a>&nbsp;&nbsp;
      <a href="#M000483">index</a>&nbsp;&nbsp;
      <a href="#M000481">insert</a>&nbsp;&nbsp;
      <a href="#M000479">new</a>&nbsp;&nbsp;
      <a href="#M000488">objects</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name">Enumerable</span>
      </div>
    </div>

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000479" class="method-detail">
        <a name="M000479"></a>

        <div class="method-heading">
          <a href="#M000479" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(rawdata = &quot;&quot;, dictionary = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Creates a <a href="ObjectStream.html#M000479">new</a> <a
href="Object.html">Object</a> <a href="Stream.html">Stream</a>.
</p>
<table>
<tr><td valign="top"><em>dictionary</em>:</td><td>A hash of attributes to set to the <a href="Stream.html">Stream</a>.

</td></tr>
<tr><td valign="top"><em>rawdata</em>:</td><td>The <a href="Stream.html">Stream</a> data.

</td></tr>
</table>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000479-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000479-source">
<pre>
     <span class="ruby-comment cmt"># File origami/stream.rb, line 414</span>
414:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">rawdata</span> = <span class="ruby-value str">&quot;&quot;</span>, <span class="ruby-identifier">dictionary</span> = {})
415:       <span class="ruby-ivar">@objects</span> = <span class="ruby-keyword kw">nil</span>
416:      
417:       <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">rawdata</span>, <span class="ruby-identifier">dictionary</span>)
418:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000480" class="method-detail">
        <a name="M000480"></a>

        <div class="method-heading">
          <a href="#M000480" class="method-signature">
          <span class="method-name">&lt;&lt;</span><span class="method-args">(object)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Adds a <a href="ObjectStream.html#M000479">new</a> <a
href="Object.html">Object</a> to this <a href="Stream.html">Stream</a>.
</p>
<table>
<tr><td valign="top"><em>object</em>:</td><td>The <a href="Object.html">Object</a> to append.

</td></tr>
</table>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000480-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000480-source">
<pre>
     <span class="ruby-comment cmt"># File origami/stream.rb, line 451</span>
451:     <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;&lt;</span>(<span class="ruby-identifier">object</span>)
452:       <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">generation</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
453:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidObjectError</span>, <span class="ruby-value str">&quot;Cannot store an object with generation &gt; 0 in an ObjectStream&quot;</span>
454:       <span class="ruby-keyword kw">end</span>
455: 
456:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Stream</span>)
457:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidObjectError</span>, <span class="ruby-value str">&quot;Cannot store a Stream in an ObjectStream&quot;</span>
458:       <span class="ruby-keyword kw">end</span>
459: 
460:       <span class="ruby-identifier">load!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">nil?</span>
461:       
462:       <span class="ruby-identifier">object</span>.<span class="ruby-identifier">no</span>, <span class="ruby-identifier">object</span>.<span class="ruby-identifier">generation</span> = <span class="ruby-ivar">@pdf</span>.<span class="ruby-identifier">alloc_new_object_number</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">no</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
463:       
464:       <span class="ruby-identifier">object</span>.<span class="ruby-identifier">set_indirect</span>(<span class="ruby-keyword kw">true</span>) <span class="ruby-comment cmt"># object is indirect</span>
465:       <span class="ruby-identifier">object</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-keyword kw">self</span>      <span class="ruby-comment cmt"># set this stream as the parent</span>
466:       <span class="ruby-identifier">object</span>.<span class="ruby-identifier">set_pdf</span>(<span class="ruby-ivar">@pdf</span>)      <span class="ruby-comment cmt"># indirect objects need pdf information</span>
467:       <span class="ruby-ivar">@objects</span>[<span class="ruby-identifier">object</span>.<span class="ruby-identifier">no</span>] = <span class="ruby-identifier">object</span>
468:      
469:       <span class="ruby-constant">Reference</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">object</span>.<span class="ruby-identifier">no</span>, <span class="ruby-value">0</span>)
470:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000482" class="method-detail">
        <a name="M000482"></a>

        <div class="method-heading">
          <a href="#M000482" class="method-signature">
          <span class="method-name">delete</span><span class="method-args">(no)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Deletes <a href="Object.html">Object</a> <em>no</em>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000482-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000482-source">
<pre>
     <span class="ruby-comment cmt"># File origami/stream.rb, line 476</span>
476:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">no</span>)
477:       <span class="ruby-identifier">load!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">nil?</span>
478: 
479:       <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">no</span>)
480:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000487" class="method-detail">
        <a name="M000487"></a>

        <div class="method-heading">
          <a href="#M000487" class="method-signature">
          <span class="method-name">each</span><span class="method-args">(&amp;b)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Iterates over <a href="ObjectStream.html#M000487">each</a> object in the
stream.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000487-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000487-source">
<pre>
     <span class="ruby-comment cmt"># File origami/stream.rb, line 529</span>
529:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
530:       <span class="ruby-identifier">load!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">nil?</span> 
531:       
532:       <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">each</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
533:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000484" class="method-detail">
        <a name="M000484"></a>

        <div class="method-heading">
          <a href="#M000484" class="method-signature">
          <span class="method-name">extract</span><span class="method-args">(no)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a given decompressed object contained in the <a
href="Stream.html">Stream</a>.
</p>
<table>
<tr><td valign="top"><em>no</em>:</td><td>The <a href="Object.html">Object</a> number.

</td></tr>
</table>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000484-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000484-source">
<pre>
     <span class="ruby-comment cmt"># File origami/stream.rb, line 500</span>
500:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extract</span>(<span class="ruby-identifier">no</span>)
501:       <span class="ruby-identifier">load!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">nil?</span>
502:     
503:       <span class="ruby-ivar">@objects</span>[<span class="ruby-identifier">no</span>]
504:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000485" class="method-detail">
        <a name="M000485"></a>

        <div class="method-heading">
          <a href="#M000485" class="method-signature">
          <span class="method-name">extract_by_index</span><span class="method-args">(index)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a given decompressed object by <a
href="ObjectStream.html#M000483">index</a>.
</p>
<table>
<tr><td valign="top"><em><a href="ObjectStream.html#M000483">index</a></em>:</td><td>The <a href="Object.html">Object</a> <a
href="ObjectStream.html#M000483">index</a> in the <a
href="ObjectStream.html">ObjectStream</a>.

</td></tr>
</table>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000485-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000485-source">
<pre>
     <span class="ruby-comment cmt"># File origami/stream.rb, line 510</span>
510:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extract_by_index</span>(<span class="ruby-identifier">index</span>)
511:       <span class="ruby-identifier">load!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">nil?</span>
512: 
513:       <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">sort</span>[<span class="ruby-identifier">index</span>]
514:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000486" class="method-detail">
        <a name="M000486"></a>

        <div class="method-heading">
          <a href="#M000486" class="method-signature">
          <span class="method-name">include?</span><span class="method-args">(no)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns whether a specific object is contained in this stream.
</p>
<table>
<tr><td valign="top"><em>no</em>:</td><td>The <a href="Object.html">Object</a> number.

</td></tr>
</table>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000486-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000486-source">
<pre>
     <span class="ruby-comment cmt"># File origami/stream.rb, line 520</span>
520:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include?</span>(<span class="ruby-identifier">no</span>)
521:       <span class="ruby-identifier">load!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">nil?</span>
522:     
523:       <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">no</span>)
524:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000483" class="method-detail">
        <a name="M000483"></a>

        <div class="method-heading">
          <a href="#M000483" class="method-signature">
          <span class="method-name">index</span><span class="method-args">(no)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the <a href="ObjectStream.html#M000483">index</a> of <a
href="Object.html">Object</a> <em>no</em>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000483-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000483-source">
<pre>
     <span class="ruby-comment cmt"># File origami/stream.rb, line 485</span>
485:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">index</span>(<span class="ruby-identifier">no</span>)
486:       <span class="ruby-identifier">ind</span> = <span class="ruby-value">0</span>
487:       <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">num</span>, <span class="ruby-identifier">obj</span><span class="ruby-operator">|</span>
488:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ind</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">num</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">no</span>
489: 
490:         <span class="ruby-identifier">ind</span> = <span class="ruby-identifier">ind</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
491:       }
492: 
493:       <span class="ruby-keyword kw">nil</span>
494:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000481" class="method-detail">
        <a name="M000481"></a>

        <div class="method-heading">
          <span class="method-name">insert</span><span class="method-args">(object)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for #&lt;&lt;
</p>
        </div>
      </div>

      <div id="method-M000488" class="method-detail">
        <a name="M000488"></a>

        <div class="method-heading">
          <a href="#M000488" class="method-signature">
          <span class="method-name">objects</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the array of inner <a href="ObjectStream.html#M000488">objects</a>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000488-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000488-source">
<pre>
     <span class="ruby-comment cmt"># File origami/stream.rb, line 538</span>
538:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">objects</span>
539:       <span class="ruby-identifier">load!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">nil?</span>
540:     
541:       <span class="ruby-ivar">@objects</span>.<span class="ruby-identifier">values</span>
542:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>